<!DOCTYPE html>
<html>

	<head>
		<meta charset="utf-8">
		<meta name="viewport" content="width=device-width,initial-scale=1,minimum-scale=1,maximum-scale=1,user-scalable=no" />
		<title></title>
		<link href="../css/mui.min.css" rel="stylesheet" />
		<script src="http://lib.sinaapp.com/js/jquery/1.12.4/jquery-1.12.4.min.js "></script>

		<link rel="stylesheet" type="text/css" href="../css/icons-extra.css" />
		<!--App自定义的css-->
		<link rel="stylesheet" type="text/css" href="../css/app.css" />
		<style>
			html,
			body {
				background-color: #efeff4;
				overflow: hidden;
			}
			
			.mui-locker {
				margin: 35px auto;
			}
			
			#forget {
				display: block;
				margin-top: 10px;
				text-align: center;
			}
			
			h5 {
				margin-top: 10px;
			}
			
			.bkys {
				text-align: center;
				border-style: ridge;
				border-radius: 8px 8px 8px 8px;
				/*background:#4CD964;*/
				width: 30%;
				float: left;
				margin-top: 20px;
				margin-left: ;
			}
		</style>
	</head>

	<body>
		<header class="mui-bar mui-bar-nav" style="height: 55px;">
			<a class="mui-action-back mui-icon mui-icon-left-nav mui-pull-left" style="margin-top: 15px;"></a>
			<h1 class="mui-title" style="margin-top: 15px;">评价</h1>
		</header>
		<div id="" style="height: 70px;"></div>
		<div id="" style="margin-left: 10%;width: 100%;">
			<h5 style="float: left;">总体评价：</h5>
			<div id="" style="background:;margin-top: 10px;">

				<div id="" style="width: 10%;float: left;" onclick="iconschange(1)">
					<a id="ic_1"><span class="mui-icon-extra mui-icon-extra-heart"></span></a>
					<a id="icf_1" style="display: none;"><span class="mui-icon-extra mui-icon-extra-heart-filled"></span></a>
				</div>
				<div id="" style="width: 10%;float: left;" onclick="iconschange(2)">
					<a id="ic_2"><span class="mui-icon-extra mui-icon-extra-heart"></span></a>
					<a id="icf_2" style="display: none;"><span class="mui-icon-extra mui-icon-extra-heart-filled"></span></a>
				</div>
				<div id="" style="width: 10%;float: left;" onclick="iconschange(3)">
					<a id="ic_3"><span class="mui-icon-extra mui-icon-extra-heart"></span></a>
					<a id="icf_3" style="display: none;"><span class="mui-icon-extra mui-icon-extra-heart-filled"></span></a>
				</div>
				<div id="" style="width: 10%;float: left;" onclick="iconschange(4)">
					<a id="ic_4"><span class="mui-icon-extra mui-icon-extra-heart"></span></a>
					<a id="icf_4" style="display: none;"><span class="mui-icon-extra mui-icon-extra-heart-filled"></span></a>
				</div>
				<div id="" style="width: 10%;float: left;" onclick="iconschange(5)">
					<a id="ic_5"><span class="mui-icon-extra mui-icon-extra-heart"></span></a>
					<a id="icf_5" style="display: none;"><span class="mui-icon-extra mui-icon-extra-heart-filled"></span></a>
				</div>

			</div>
		</div>

		<div id="" style="margin-top:60px ;margin-left: 10%;">
			<h5 style="margin-top: ;margin-left:;">添加标签：</h5>
			<!--<hr class="hrLine" style="width: 30%;float: left;" /><h5 style="margin-top: ;margin-left:;float: left;">添加标签：</h5>
		    <hr class="hrLine" style="width: 30%;float: left;" />-->
		</div>

		<div id="" style="background:;margin-left: 10%;">
			<div id="skill" style="margin-left: ;">

				<div style="width: 100%;float: ;margin-top: 10px;visibility:hidden;">
					<input type="checkbox" value="" />
				</div>
			</div>
		</div>
		<div id="" style="margin-left:10%;width: 80%;background: white;height: 100px;margin-top: 160px; border:1px">

			<textarea name="a" id="a" style="width:80%;height:100px;border: none;" placeholder="评价："></textarea>

		</div>
		<div id="">
			<button style="margin-top: 20px;margin-left:10%;width: 80%;height: 50px;" onclick="submit()">提交</button>
		</div>

		<script src="../js/mui.min.js"></script>
		<script src="../js/mui.locker.js"></script>
		<script src="../js/urlconfiguration.js"></script>
		<script type="text/javascript">
			var skills = [];
			var jobitem_user_id;
			var skilllength;
			var seletedheard = 0;
			var seletedtitle = "0";
			var pingjia;

			var titlenum = [];
			titlenum[0] = 0;
			for(i = 1; i < 8; i++) {
				titlenum[i] = 0;
			}

			mui.plusReady(function() {
				var self = plus.webview.currentWebview();
				jobtype_id = self.jobtype_id;
				jobitem_user_id = self.jobitem_user_id;
				appraiser_id = self.userid;
				appraiseobject_id = self.jobuserid;
				flag = self.evaluationflag;
				console.log(jobtype_id + "/" + jobitem_user_id + "/" + appraiser_id + "/" + appraiser_id + "/" + appraiseobject_id + "/" + flag);
				abc();
			})

			function iconschange(obj) {
				seletedheard = parseInt(obj);
				num = parseInt(obj);
				for(i = 1; i < 6; i++) {
					if(i <= num) {
						document.getElementById("ic_" + i).style.display = "none";
						document.getElementById("icf_" + i).style.display = "";
					} else {
						document.getElementById("ic_" + i).style.display = "";
						document.getElementById("icf_" + i).style.display = "none";
					};
				}
			}

			function abc() {
				$.ajax({
					contentType: "application/json",
					type: "GET",
					url: url_1 + "show_label.do?jsoncallback=?",
					data: "jobtype_id=" + 0 + "&authentic_status=" + 2,
					dataType: "json",
					success: function(data) {
						if(data.flag == 0) {
							mui.alert('查询失败', '错误', function() {});
							return;
						}
						document.getElementById("skill").innerHTML = "";

						skilllength = data.label.length;
						for(i = 0; i < skilllength; i++) {
							document.getElementById("skill").innerHTML = document.getElementById("skill").innerHTML +
								'<button id="' + data.label[i].id + '" name="0" type="button" class="mui-btn mui-btn-primary mui-btn-outlined bkys" onclick="titlechange(this)">' + data.label[i].name + '</button>'
							skills[i] = data.label[i].id;
						}

					},
					error: function() {
						mui.alert('网络连接错误', '错误', function() {});
					}
				});
			}

			function titlechange(obj) {
				if(obj.name == 0) {
					obj.setAttribute("class", "mui-btn mui-btn-primary bkys");
					obj.name = 1;
				} else if(obj.name == 1) {
					obj.setAttribute("class", "mui-btn mui-btn-primary mui-btn-outlined bkys");
					obj.name = 0;
				}
			}

			function submit() {
				console.log("2");
				pingjia = document.getElementById("a").value;
				for(i = 0; i < skilllength; i++) {
					if(document.getElementById(skills[i]).name == 1) {
						if(seletedtitle == "0") {
							seletedtitle = skills[i];
						} else
							seletedtitle = seletedtitle + "_" + skills[i];
					}
				}

				//seletedheard    星级
				//flag   1：工长评价个人   2：工人评价工长
				//pingjia  评价语
				//

				var w1 = plus.nativeUI.showWaiting("正在读取...\n", {

				});
				$.ajax({
					contentType: "application/json",
					type: "GET",
					url: url_1 + "add_appraise.do?jsoncallback=?",
					data: "jobitem_user_id=" + jobitem_user_id + "&appraiser_id=" + appraiser_id + "&appraiseobject_id=" + appraiseobject_id + "&labels_id=" + seletedtitle + "&context=" + pingjia + "&appraise_score=" + seletedheard + "&flag=" + flag,
					dataType: "json",
					success: function(data) {
						console.log("1");
						var timeset = 1;
						var timer = setInterval(function() {
							if(timeset == 0) {
								clearInterval(timer);
								w1.close();
							} else {
								--timeset;
							}
						}, 1000);
						if(data.flag == 1) {
							w1.close();
							mui.toast('评价成功');
							var old_back = mui.back;
							old_back();
							var list = plus.webview.currentWebview().opener();
							//触发父页面的自定义事件(refresh),从而进行刷新
							mui.fire(list, 'tomypublish');
							//返回true,继续页面关闭逻辑
							return true;

						}
						if(data.flag == 0) {
							w1.close();
							mui.alert('发生未知错误，评价失败', '数据错误', function() {});
						}
					},
					error: function() {
						w1.close();
						mui.alert('网络连接错误', '错误', function() {});
					}
				});
			}
		</script>

		<!--<script src="../js/app.js"></script>-->

	</body>

</html <!--1：工长评价工人 2：工人评价工长-->